import axios from '@/utils/axios'

export interface UserInfo {
    userId: number
    email: string
    nickname: string
    avatar: string
    intro: string
    level: number
    lastLoginTime: string
}

export interface CurrentUserResponse {
    code: number
    msg: string
    data: UserInfo
}

// 获取当前用户信息
export const getCurrentUser = (): Promise<CurrentUserResponse> => {
    const token = localStorage.getItem('token');

    return axios.get('/users/current', {
        headers: { 'Authorization': `Bearer ${token}` }
    })
}
